clear all
set more off
cd ""

use "sample.dta", clear

**********
* Panel A
**********

* Generate time-to-event dummies
* Transformation to get linear combinations of parameters

tab rel_time, gen(rel_w)
gen rel_w11_21 = rel_w11*21
forvalue i = 12/31 {
gen diff_rel`i'_11 = rel_w`i' - rel_w11
}

reghdfe d_movewithin rel_w11_21 diff_rel* wdsp temp prcp, absorb(i.city_code i.time i.prov_code#c.time i.prov_code#c.time2) cluster(time)

reghdfe bdindex_std rel_w11_21 diff_rel* wdsp temp prcp, absorb(i.city_code i.time i.prov_code#c.time) cluster(time)

reghdfe bdindex7_std rel_w11_21 diff_rel* wdsp temp prcp, absorb(i.city_code i.time i.prov_code#c.time) cluster(time)

reghdfe bdindexS7_std rel_w11_21 diff_rel* wdsp temp prcp, absorb(i.city_code i.time i.prov_code#c.time) cluster(time)

**********
* Panel B
**********

* Generate interaction terms between time-to-event dummies and faction
* Transformation to get linear combinations of parameters

forvalue i = 1/31 {
gen rel_w`i'_D = rel_w`i' * faction
}
gen rel_w11_D_21 = rel_w11_D*21
forvalue i = 12/31 {
gen diff_Drel`i'_11 = rel_w`i'_D - rel_w11_D
}

reghdfe d_movewithin rel_w11_D_21 diff_Drel* treat_csm wdsp temp prcp, absorb(i.city_code#i.faction i.time#i.faction i.prov_code#c.time#i.faction i.prov_code#c.time2#i.faction) cluster(time)

reghdfe bdindex_std rel_w11_D_21 diff_Drel* treat_csm wdsp temp prcp, absorb(i.city_code#i.faction i.time#i.faction i.prov_code#c.time#i.faction) cluster(time)

reghdfe bdindex7_std rel_w11_D_21 diff_Drel* treat_csm wdsp temp prcp, absorb(i.city_code#i.faction i.time#i.faction i.prov_code#c.time#i.faction) cluster(time)

reghdfe bdindexS7_std rel_w11_D_21 diff_Drel* treat_csm wdsp temp prcp, absorb(i.city_code#i.faction i.time#i.faction i.prov_code#c.time#i.faction) cluster(time)
